import screens.screen
from pygame.locals import *
import pygame
from pygameExt import pygameext, textrect

class textScreen(screens.screen.screeninherit):
    def __init__(self, screen, message, nextscene, person="", screenname=""):
        #show a picture of the character etc.
        self.message=message
        self.currentmessage=0
        self.newscene = nextscene
        self.nextscene = 0
        self.screen = screen
        spaceListener = screens.screen.keyListener(K_SPACE, self.onSpace())
        self.keylisteners = [spaceListener]
        
    def init(self):
            pygameext.clearSurface(self.screen)
            pygameext.textScreenWidget(self.message[self.currentmessage], self.screen)
            pygameext.Ezwrite("Press Space to continue", self.screen, 20, 300, 600, 100, 50)
            pygame.display.flip()
               
    def onSpace(self):
            self.currentmessage+=1
            if (self.currentmessage > len(self.message)-1):
              self.nextscene = self.newscene
              return
            pygameext.textScreenWidget(self.message[self.currentmessage], self.screen)

    def loop(self):
        return